package ooday03test2;

public class RefArrayDemo {
    public static void main(String[] args) {
        //
        Dog[] dogs=new Dog[3];
        dogs[0]=new Dog("小黑1",8,"黑");
        dogs[1]=new Dog("小黑2",8,"黑");
        dogs[2]=new Dog("小黑3",8,"黑");
        dogs[0].age=5;
        dogs[2].swim();
        for (int i=0;i<dogs.length;i++){
            System.out.println(dogs[i].name);
            dogs[i].eat();
        }
        //
        Chick chick=new Chick("小黄",5,"黄");
        Chick[] chicks=new Chick[2];
        chicks[0]=chick;
        chicks[1]=new Chick("小黄2",5,"黄");
        for (int i=0;i<chicks.length;i++){
            System.out.println(chicks[i].color);
            chicks[i].layEggs();
        }

        //
        Fish[] fish=new Fish[2];
        fish[0]=new Fish("小花",5,"花");
        fish[1]=new Fish("小花2",5,"花");
        for (int i=0;i<fish.length;i++){
            System.out.println(fish[i].age);
            fish[i].swim();
        }
    }
}
